<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //基类 父类
      class Person {
        constructor(name, age) {
          this.name = name;
          this.age = age;
        }
        eat() {
          console.log("吃eat!!!");
        }
      }
      //子类
      class Student extends Person {
        do() {
          console.log("学习");
        }
      }
      class Student1 extends Person {
        do() {
          console.log("学习");
        }
      }
      class Student2 extends Person {
        do() {
          console.log("学习");
        }
      }
      class Student3 extends Person {
        do() {
          console.log("学习");
        }
      }
      //得到一个子类的实例化对象
      //如果想要所有的Student的实例化对象都有一个公有属性,则可以直接设置给Student.prototype上
      const s1 = new Student();
      const s2 = new Student();
      const s3 = new Student();

      console.log(s1);
      console.log(s1.__proto__); //Student.prototype
      console.log(s1.__proto__.__proto__); //Person.prototype
      console.log(s1.__proto__.__proto__.__proto__); //Object.prototype
      console.log(s1.__proto__.__proto__.__proto__.__proto__); //null

      //如果让s11 s22 s33设置一个公有属性 则最近只能设置给Person.prototype
      const s11 = new Student1();
      const s22 = new Student2();
      const s33 = new Student3();
    </script>
  </body>
</html>
